const fs = require("fs");
const path = require("path");

//创建文件夹 同步执行
const dirPath = path.join(__dirname, "test");
fs.mkdirSync(dirPath);

//将test.txt复制至新建的文件夹下
let filePath = path.join(__dirname, "test.txt");
let writePath = path.join(__dirname, "test/copy.txt");

let reader = fs.createReadStream(filePath);
let writer = fs.createWriteStream(writePath);
reader.pipe(writer);